import React from 'react'
import { changeNav } from '../../../actions'
import { connect } from 'react-redux'
import {
    Button, List, InputItem, Flex, WingBlank, WhiteSpace, Popup, Tag, Toast, Switch, Icon
} from 'antd-mobile'
import { createForm } from 'rc-form';
import styles from './../wxelm/alreadyOpenTenant.less';
import { ajaxGet, ajaxPost } from 'wxAjaxUtil';
import hhistory from '../../../history'

const Item = List.Item;
const Brief = Item.Brief;
const postData={
    "searchParam":"",
    "page":1,
    "limit":10
 };

class WxmtPutInfo extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            res:[]
        };
    }
    componentDidMount() {
        this.props.tochangeNav({
            title: "美团外卖", rbtn: [
                <Icon type={'search'} />
            ]
        });
        //请求数据
		ajaxPost("/o2o/sly/list/mtwm",postData,'wxApiPath').then(res => {
			if (res.returnCode && res.returnCode == "1") {
				this.setState({
					res: res.data.detail,
				});
			} else {
				Toast.fail('获取已开通商户失败', 1);
			}
		});
    }

    toWmConfig(code){
        hhistory.push({ pathname: '/wxmtPutInfo', state: { backRouter: '/alreadyOpenTenant',code:code } })
    }

    render() {
        
        return (
            <div>

                <WhiteSpace />
                <Flex style={{ background: "#fff", padding: "10px 0" }}>
                    <Flex.Item ><span >开通业务</span><Icon type="down" /></Flex.Item>
                    <Flex.Item ><span >到期时间</span><Icon type="down" /></Flex.Item>
                    <Flex.Item ><span >批量开通</span><Icon type="down" /></Flex.Item>
                </Flex>
                <WhiteSpace />
                <div>
                    {this.state.res.map((item, index) => {
                        return (
                            <div key={index}>
                                <Item thumb={item.storeLogo} extra={<button onClick={this.toWmConfig.bind(this,item.storeCode)} className={styles.btn} type="button">美团外卖</button>}>
                                    {item.storeName}<Brief>{item.storeCode}</Brief>
                                </Item>
                            </div>
                        )
                    })}
                </div>

            </div>
        )
    }


}

const mapStateToProps = (state) => ({

})
const mapDispatchToProps = (dispatch) => ({
    tochangeNav: navogj => dispatch(changeNav(navogj)),
})

export default connect(mapStateToProps, mapDispatchToProps)(WxmtPutInfo)